home *** CD-ROM | disk | FTP | other *** search
- global gPPTableVarObj
-
- on PPTables xFile
- if voidp(xFile) then
- alert("the parameter must be a string, with quotes")
- exit
- end if
- StartMember = the number of member "pptable1" of castLib 1
- InitPPVars(StartMember)
- FormatFile = xFile & ".for"
- FormatText = readFile(GetTextFilePath() & FormatFile)
- LineText = line 1 of FormatText
- xItems = integer(LineText)
- ObjList = []
- xMember = StartMember
- repeat with rc = 1 to xItems
- DataFile = RemoveSpaces(item rc of LineText)
- append(ObjList, new(script("PP Table parent"), xMember, xFile & ".td" & rc, FormatFile))
- xMember = xMember + 1
- end repeat
- SetTableList(gPPTableVarObj, ObjList)
- CompileLinkList(FormatText)
- ParseIfNotSpan()
- ParseSpanWidths()
- FinalizeSize()
- ReadHeaderAndFootNotes(xFile, StartMember)
- updateStage()
- PPAlertFinished()
- end
-
- on ParseIfNotSpan
- TableList = GetTableObj(gPPTableVarObj)
- LinkList = GetLinkList(gPPTableVarObj)
- PenultimateList = getAt(LinkList, count(LinkList) - 1)
- LastList = getAt(LinkList, count(LinkList))
- if getAt(LastList, 1) > 1 then
- BottomTableColCount = count(PenultimateList) + count(LastList)
- else
- BottomTableColCount = count(LastList)
- end if
- OrigWhichTables = CreateLookUpList(LinkList)
- repeat with ColNum = 1 to BottomTableColCount
- WhichTables = duplicate(OrigWhichTables)
- if getAt(LastList, 1) > 1 then
- if ColNum <= count(PenultimateList) then
- position = count(LinkList)
- else
- position = count(LinkList) - 1
- end if
- deleteAt(WhichTables, position)
- end if
- SetMaxColumn(WhichTables, ColNum)
- end repeat
- end
-
- on SetMaxColumn WhichTables, mColNum
- TableObjL = GetTableObj(gPPTableVarObj)
- LinkList = GetLinkList(gPPTableVarObj)
- ColNum = mColNum
- NonSpanWidthList = []
- columnList = [0, 0, 0, 0, 0, 0]
- MaxList = count(WhichTables)
- repeat with rc = MaxList down to 1
- TableNum = getAt(WhichTables, rc)
- TableList = getAt(LinkList, TableNum)
- valuePosition = getPos(TableList, ColNum)
- if valuePosition > 0 then
- tempCol = valuePosition
- else
- exit repeat
- end if
- append(NonSpanWidthList, GetObjColWidth(getAt(TableObjL, TableNum), tempCol))
- setAt(columnList, TableNum, tempCol)
- end repeat
- MaxWidth = max(NonSpanWidthList)
- repeat with ti = 1 to count(TableObjL)
- ColNum = getAt(columnList, ti)
- if ColNum > 0 then
- SetObjColWidth(getAt(TableObjL, ti), ColNum, MaxWidth)
- end if
- end repeat
- end
-
- on FinalizeSize
- TableList = GetTableObj(gPPTableVarObj)
- LinkList = GetLinkList(gPPTableVarObj)
- LastList = getAt(LinkList, count(LinkList))
- repeat with rc in TableList
- ObjAllColumnWidths(rc)
- end repeat
- if getAt(LastList, 1) > 1 then
- HeightList = GetRowHeightList(getAt(TableList, count(TableList)))
- if count(HeightList) > 0 then
- ObjSetRowHeight(getAt(TableList, count(TableList) - 1), HeightList)
- end if
- end if
- end
-
- on CompileLinkList FormatText
- LinkList = []
- StartLine = 2
- EndLine = the number of lines in FormatText - 1
- repeat with rc = StartLine to EndLine
- append(LinkList, value(line rc of FormatText))
- end repeat
- SetLinkList(gPPTableVarObj, LinkList)
- end
-
- on InitPPVars StartMember
- gPPTableVarObj = new(script("PP Var Stuff"))
- repeat with rc = StartMember to StartMember + 5
- member(rc).tableData = []
- member(rc).rowCount = 1
- member(rc).columnCount = 1
- end repeat
- the itemDelimiter = ","
- end
-
- on ReadHeaderAndFootNotes xFile, StartMember
- set the text of field (StartMember + 6) to readFile(GetTextFilePath() & xFile & ".hd")
- set the text of field (StartMember + 7) to readFile(GetTextFilePath() & xFile & ".fn")
- end
-